<template>
  <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="1200" :height="350" @ok="handleSubmit">
      <AttTimePeriodList :ruleId="ruleId"></AttTimePeriodList>
  </BasicModal>
</template>

<script lang="ts" setup>
    import {ref, computed, unref} from 'vue';
    import {BasicModal, useModalInner} from '/@/components/Modal';
    import {BasicForm, useForm} from '/@/components/Form/index';
    import {formSchema} from '../AttRule.data';
    import {saveOrUpdate} from '../AttRule.api';
    import AttTimePeriodList from "/@/views/attendance/timeperiod/AttTimePeriodList.vue"
    // Emits声明
    const emit = defineEmits(['register','success']);
    const isUpdate = ref(true);
    const ruleId = ref();
    //表单赋值
    const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
        //重置表单
        setModalProps({confirmLoading: false,showCancelBtn:false,showOkBtn:false});
        isUpdate.value = !!data?.isUpdate;
        console.log(data);
        if (unref(isUpdate)) {
          if(data.record.attRuleId){
            ruleId.value = data.record.attRuleId;
          }else {
            ruleId.value = data.record.id;
          }
        }
    });
    //设置标题
    const title = "时间段"

</script>

<style lang="less" scoped>
	/** 时间和数字输入框样式 */
  :deep(.ant-input-number){
		width: 100%
	}

	:deep(.ant-calendar-picker){
		width: 100%
	}
</style>
